package indi.zhifa.recipe.bailan.framework.auth.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.DataPermissionInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import indi.zhifa.recipe.bailan.framework.auth.filter.DataPermissionAop;
import indi.zhifa.recipe.bailan.framework.mysql.config.BaseMybatisPlusConfig;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Slf4j
@AllArgsConstructor
@Configuration
public class AuthMybatisPlusConfig {

    private final DataPermissionAop mDataPermissionAop;
    private final MybatisPlusInterceptor mMybatisPlusInterceptor;



    @PostConstruct
    public void mybatisPlusInterceptor() {

        //  数据权限
        DataPermissionInterceptor dataPermissionInterceptor = new DataPermissionInterceptor();
        dataPermissionInterceptor.setDataPermissionHandler(mDataPermissionAop);
        mMybatisPlusInterceptor.addInnerInterceptor(dataPermissionInterceptor);
        log.info("======================AuthMybatisPlusConfig==========================");
    }
}
